/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 *  1 2 3 4 5
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function (head) {
  let l = new ListNode(null)
  let p = head
  while(p){
    let r = p
    r.next=l.next
    l.next=r
    p=p.next
  }
  return l
};